package com.winchain.chainbill.bill.biz.send.rx;

import com.shell.framework.command.ChainBase;
import com.shell.framework.command.CommandContext;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.bill.biz.send.cmd.BillInvoiceRejectCmd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillInvoiceRejectSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<? extends Object>> {
	@Autowired
	private BillInvoiceRejectCmd billInvoiceRejectCmd;

	public void onApplicationEvent(BillEvent<? extends Object> t) {
		Bill<?> bill = t.getBill();
		CommandContext<Bill<?>> context = new CommandContext();
		context.setSource(bill);
		context.setValue("bizId", t.getStringValue("bizId"));
		context.setValue("invType", t.getStringValue("invType"));
		ChainBase<Bill<?>> crb = new ChainBase();
		crb.add(this.billInvoiceRejectCmd);
		crb.execute(context);
	}
}
